home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’89 / ErrApp / ErrApp.inc1.p < prev    next >
Encoding:
Text File  |  1989-06-16  |  4.0 KB  |  165 lines  |  [TEXT/MPS ]

  1.  
  2. Procedure DoAddrErr; external;
  3. Procedure DoillErr; external;
  4. Procedure DoPrivErr; external;
  5. Procedure DoTraceErr; external;
  6. Procedure DoFTrap; external;
  7. Procedure GetResPatch; external;
  8. procedure DoPack1; external;
  9.  
  10.  
  11. Procedure InstallPatch ( pack: Integer );
  12.     var l: LongPtr;
  13.     
  14.     begin
  15.     l := LongPtr ( $AB8 + ( pack * 4 ));
  16.     l^ := 0;
  17.     l := LongPtr ( $A78 );
  18.     l^ := GetTrapAddress ( $A9A0 );
  19.     SetTrapAddress ( LongInt ( @GetResPatch ), $A9A0 );
  20. end;
  21.  
  22. Procedure RemovePatch;
  23.     var l: LongPtr;
  24. begin
  25.     l := LongPtr ( $A78 );
  26.     SetTrapAddress ( l^, $A9A0 );
  27. end;
  28.  
  29. Procedure StkOverFlow;
  30. var bigJunk: array [ 0 .. 30000 ] of Integer;
  31.     l: LongInt;
  32.     
  33.     begin
  34.     Delay ( 2, l );
  35.     StkOverFlow;
  36.     end;
  37.     
  38. Procedure DoSystemError ( sysError: Integer );
  39.     type
  40.         IntPtr=^Integer;
  41.     var
  42.         i, j, k: Integer;
  43.         l, m: Size;
  44.         ip:IntPtr;
  45.         anArray:array [0..1] of integer;
  46.         h: Handle;
  47.         tz: THz;
  48.         lh:ListHandle;
  49.         x,y,z:extended;
  50.         where:Point;
  51.         reply:SFReply;
  52.         aTypeList:SFTypeList;
  53.         
  54.     begin
  55.     case sysError of
  56.          1:    { Bus Error }
  57.              begin
  58.                 ip:=IntPtr(-1);
  59.                 i:=ip^;
  60.             end;
  61.          2:    DoAddrErr;    { Address Error }
  62.          3: DoillErr;    { Illegal Instuction Error }
  63.          4: j := i div 0;    { Divide by zero Error }
  64.          5: { Check Trap Error }
  65.              begin
  66.                  j := 32767;
  67.                  i:=anArray[j];
  68.             end;
  69.          6: ;    { Overflow Trap Error }
  70.          7: DoPrivErr;    { Privilege violation Error }
  71.          8: DoTraceErr;    { Trace Mode Error }
  72.          9: ;    { line 1010 trap Error }
  73.         10: DoFTrap;    { line 1111 trap Error }
  74.         11: ;    { misc hardware exception Error }
  75.         12: ;    { Unimplemented core routine Error }
  76.         13: ;    { Uninstalled interrupt Error }
  77.         14: ;    { I/O Core Error }
  78.         15: ;    { Segment Loader Error }
  79.         16: ;    { Floating Point Error }
  80. (*
  81. listMgr = 0;                                {list manager}
  82. dskInit = 2;                                {Disk Initializaton}
  83. stdFile = 3;                                {Standard File}
  84. flPoint = 4;                                {Floating-Point Arithmetic}
  85. trFunc = 5;                                 {Transcendental Functions}
  86. intUtil = 6;                                {International Utilities}
  87. bdConv = 7;                                 {Binary/Decimal Conversion}
  88. *)
  89.         17: begin    { Package 0 Not Present }
  90.             InstallPatch ( 0 );
  91.             LDispose(lh);
  92.             RemovePatch;
  93.             end;
  94.         18: begin    { Package 1 Not Present }
  95.             InstallPatch ( 1 ) ;
  96.             DoPack1;
  97.             RemovePatch;
  98.             end;
  99.         19: begin    { Package 2 Not Present }
  100.             InstallPatch ( 2 );
  101.             Debugger;
  102.             DILoad;
  103.             RemovePatch;
  104.             end;
  105.         20: begin    { Package 3 Not Present }
  106.             InstallPatch ( 3 );
  107.             SFGetFile(where,'',NIL,1,aTypeList,NIL,reply);
  108.             RemovePatch;
  109.             end;
  110.         21: begin    { Package 4 Not Present }
  111.             InstallPatch ( 4 );
  112.             x:=x*y;
  113.             RemovePatch;
  114.             end;
  115.         22: begin    { Package 5 Not Present }
  116.             InstallPatch ( 5 );
  117.             x:=sin(y);
  118.             RemovePatch;
  119.             end;
  120.         23: begin    { Package 6 Not Present }
  121.             InstallPatch ( 6 );
  122.             If IUMetric then;
  123.             RemovePatch;
  124.             end;
  125.         24: begin    { Package 7 Not Present }
  126.             InstallPatch ( 7 );
  127.             StringToNum ( '123', l );
  128.             RemovePatch;
  129.             end;
  130.         25: begin     { Memory Full Error }
  131.                 while ( TRUE ) do begin
  132.                     Debugger;
  133.                     m := Size ( 2000 );
  134.                     l := MaxMem ( m );
  135.                     if ( m <= 0 ) then
  136.                         m := 100;
  137.                      h := NewHandle ( l );
  138.                 end;
  139.             end;
  140.         26: ;    { Can't Launch File }
  141.         27: ;    { File System Map has been trashed }
  142.         28: StkOverFlow;    { stack has moved into the application heap }
  143.         29: ;    { !! Not in Errors.h !! }
  144.         30: MySysError ( 30 );    { request user to insert off-line volume }
  145.         31: MySysError ( 31 );    { Not the disk I wanted }
  146.         32: ;    { !! Not in Errors.h !! }
  147.         33: begin        { ZcbFree has gone negative }
  148.                 h := NewHandle ( 10 );
  149.                 tz := GetZone;
  150.                 tz^.zcbFree := -1;
  151.                 DisposHandle ( h );
  152.             end;                
  153.         34: ;    { !! Not in Errors.h !! }
  154.         35: ;    { !! Not in Errors.h !! }
  155.         36: ;    { !! Not in Errors.h !! }
  156.         37: ;    { !! Not in Errors.h !! }
  157.         38: ;    { !! Not in Errors.h !! }
  158.         39: ;    { !! Not in Errors.h !! }
  159.         40: MySysError ( 40 );    { Welcome to Macintosh }
  160.         41: MySysError ( 41 );    { Can't load the finder }
  161.         42: MySysError ( 42 );    { ShutDown Alert }
  162.         end;
  163.     end;
  164.  
  165.